/**
 * Copyright (C) 2010 VMWare, Inc. All Rights Reserved
 */

package org.loujiarong.yugioh.gameplay.database;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;

/**
 * JobDAO is the data object of table Job in the database
 *
 * @author jlou
 */
public class CardNameClassMappingDAO
{
   public static synchronized
   String getClassNameFromCn(String nameCn) {
      Connection con = null;
      Statement stmt = null;
      ResultSet rs = null;
      try {
         con = DatabaseCoordinator.getConnection();

         stmt = con.createStatement();
         rs = stmt.executeQuery("SELECT * from cardnameclass where nameCn='" + nameCn +"'");
         if (rs.next()) {
            String className = rs.getString("class");
            DatabaseCoordinator.releaseConnection(con);
            return className;
         } else {
            DatabaseCoordinator.releaseConnection(con);
         }
      } catch (SQLException ex) {
         try {
            if (con != null) {
               con.close();
            }
         } catch (SQLException ex2) {
         }
      } finally {
         try {
            if (stmt != null) {
               stmt.close();
            }
            if (rs != null) {
               rs.close();
            }
         } catch (SQLException ex) {
         }
      }
      return null;
   }

}
